<template>
    <container type="top-header" :show="{header:formShow}" class="g-width100 g-height100" header-style="height:auto;" main-style="padding:0;">
        <Form slot="header" inline
              submit-bus-key="ActivityManageList"
              :form-items="formItems"
              label-width=""
        ></Form>
        <Table slot="main"
               ref="table"
               form-submit-bus-key="ActivityManageList"
               :columns="columns"
               :operations="tableOperations"
               unique-label="name"
               v-on:toolbarSearchClick="formShow = !formShow"
        ></Table>
    </container>
</template>

<script>
    import Container from '../../../../common-util/src/components/page/Container.vue'
    import Form from '../../../../common-util/src/components/page/Form.vue'
    import Table from '../../../../common-util/src/components/page/Table.vue'

    export default {
        components:{
            Form,
            Table,
            Container
        },
        data(){
            return {
                formShow: true,
                formItems:[
                    {
                        field: {
                            name: 'code'
                        },
                        element:{
                            label: '活动编号',
                        }
                    },
                    {
                        field: {
                            name: 'title'
                        },
                        element:{
                            label: '活动标题',
                        }
                    },

                    {
                        field: {
                            name: 'placeTypeDictId'
                        },
                        element:{
                            type: 'selectDict',
                            selectDict:{
                                groupCode: 'activity_place_type'
                            },
                            label: '场地类型',
                        }
                    },

                    {
                        field: {
                            name: 'categoryDictId'
                        },
                        element:{
                            type: 'selectDict',
                            selectDict:{
                                groupCode: 'activity_category'
                            },
                            label: '分类',
                        }
                    },
                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'get',
                                    url: this.$baseURL.composite + '/composite/activity/listPage',
                                    label: '查询'
                                },
                                {
                                    action: 'reset',
                                    label: '重置'
                                }
                            ]
                        }
                    }
                ],
                columns:[
                    {
                        prop: 'titleUrl',
                        label:'封面图',
                        formatType: 'image'
                    },
                    {
                        prop: 'title',
                        label:'活动标题'
                    },
                    {
                        prop: 'introduced',
                        label:'活动简介'
                    },
                    {
                        prop: 'sponsor',
                        label:'主办方',
                        showInDetail: true
                    },
                    {
                        prop: 'sponsorLink',
                        label:'主办方链接',
                        showInDetail: true
                    },
                    {
                        prop: 'author',
                        label:'作者'
                    },
                    {
                        prop: 'startAtTxt',
                        label:'开始时间'
                    },
                    {
                        prop: 'endAtTxt',
                        label:'结束时间'
                    },
                    {
                        prop: 'address',
                        label:'活动地点'
                    },
                    {
                        prop: 'contact',
                        label:'联系方式',
                        showInDetail: true
                    },
                    {
                        prop: 'placeTypeDictName',
                        label:'场地类型'
                    },
                    {
                        prop: 'isPublished',
                        label:'发布状态'
                    },
                    {
                        prop: 'activityStatement',
                        label:'活动声明',
                        showInDetail: true
                    },
                    {
                        prop: 'seq',
                        label:'序号',
                        showInDetail: true
                    },
                    {
                        prop: 'enrollLink',
                        label:'报名链接',
                        showInDetail: true
                    },
                    {
                        prop: 'categoryDictName',
                        label:'分类'
                    },
                ],
                tableOperations:[
                    {
                        action: 'nav',
                        url:'/activity/activityAdd',
                        label: '添加'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/activity/activityEdit/:id',
                        label: '编辑'
                    },
                    {
                        action: 'enableOrDisable',
                        enableOrDisable:{
                            prop:'isPublished',
                            reasonProp:'publishedReason'
                        },
                        url:(row) => {return this.$baseURL.composite +  '/composite/activity/'+ row.id +'/publish'},
                        disabledOnMissingSelect:true,
                        prompt: (row)=> {return '请输入'+ (row.isPublished ? '取消发布': '发布') +'原因'},
                        label:(row) => {
                            if(row){
                                return row.isPublished ? '取消发布': '发布'
                            }else {
                                return '发布/取消发布'
                            }
                        }
                    },
                    {
                        action: 'detail',
                        disabledOnMissingSelect:true,
                        label: '详情'
                    },
                    {
                        action: 'delete',
                        url:this.$baseURL.composite + '/composite/activity/:id',
                        disabledOnMissingSelect:true,
                        label:'删除'
                    }
                ]
            }
        }
    }
</script>

<style scoped>

</style>